package com.smart.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

/**
 * Created by khan on 15-2-14.
 */
@Repository
public class OrderDao {
    @Autowired
    private  JdbcTemplate jdbcTemplate;
    public boolean addOrderToCart(int goodsid,long cartid){
        long timestamp = Long.valueOf(System.currentTimeMillis())*1000*1000+goodsid;
        String sql = "INSERT INTO `order` VALUES ("+timestamp+","+goodsid+","+cartid+","+1+")";

       System.out.println(sql);

       int count = jdbcTemplate.update(sql);
        System.out.print(count);
        if (count == 1){
            return true;
        }
        else {
            return false;
        }
    }

}
